export default {
	getUserInfo() {
		const db = this.database();
		const userCol = db.collection('user');
		return userCol.get();
	},

	async addUserInfo({ data }) {
		const db = this.database();
		const userCol = db.collection('user');
		if (data) {
			const userInfo = {
				nickName: data.nickName,
				telephone: data.telephone,
				editTimeStamp: new Date().getTime(),
				points: 0,
				birthday: '2021-01-01',
				credentialNo: '',
				deviceList: [],
				coupons: [
					{
						title: '新用户享受红包',
						type: 'reduce',
						reduce: 5,
						limit: 20,
						expireTime: new Date().getTime(),
						effectiveTime:
							new Date().getTime() + 1000 * 60 * 60 * 24 * 5,
						des: '限新用户使用',
					},
				],
			};
			wf.getModule('reporter').report('custom', 'addUserInfo', {
				userInfo,
			});
			return userCol.add(userInfo);
		}
		return Promise.reject({});
	},
};
